package com.edu.whty.common.constants;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.edu.whty.common.tools.SysConfig;
import org.apache.commons.lang.StringUtils;

import java.util.*;

public class Constant {
    public static final String CAS_SERVER_LOGIN_URL = "CasLoginUrl";
    public static final String CAS_SERVER_NAME = "ServiceUrl";
    public static final String AREACODE = "AreaCode";

    public static int MAX_RESULT_PER_PAGE = 10;  // 每页显示的最大行数

    //数据库中数据状态
    public static final Long STATE_VALID = 1L;//有效
    public static final Long STATE_INVALID = 0L;//无效
    /**
     * 有效
     */
    public static final String STATE_VALID_STRING = "1";//有效
    public static final String STATE_INVALID_STRING = "0";//无效

    public static final String IS_PACKAGE = "1";//已打包
    public static final String NOT_PACKAGE = "0";//没有打包

    //状态
    public static final String STATE_UNAUDITED = "0"; //注销
    public static final String STATE_AUDITED = "1"; //有效

    public static final String UPLOAD_LINUX_PATH = "upload_linux_path";//add by hj

    //业务状态
    public static final String SUCCESS_CODE = "000000";//操作成功
    public static final String FAIL_CODE = "111111";//操作失败

    /* message code */
    public static String SUCCESS_MESSAGE = "success";
    public static String FAILED_CODE = "100000";
    public static String FAILED_MESSAGE = "failed";
    public static final String SHARE_TYPE4 = "4";//分享类型
    public static final String FILETYPE1 = "1";//文件类型
    public static final String FILETYPE2 = "2";//文件类型
    public static final String FILETYPE3 = "3";//文件类型
    public static final String FILETYPE4 = "4";//文件类型
    public static String POST_COMPLETE_YES = "true"; // 文件流提交完成
    public static String POST_COMPLETE_NO = "false"; // 文件流未提交完成
    public static int BUFFER_SIZE = 10 * 1024;
    //业务状态
    public static final String STATUS_0 = "0"; //正常
    public static final String STATUS_1 = "1"; //失效


    //资源类型 0:课堂实录 1:板书;2:学生作品;3:学生答题;4:资源数据 5互动额他资源;6手写板

    public static final String INTERACTIVE_0 = "0"; //
    public static final String INTERACTIVE_1 = "1"; //
    public static final String INTERACTIVE_2 = "2"; //
    public static final String INTERACTIVE_3 = "3"; //
    public static final String INTERACTIVE_4 = "4"; //
    public static final String INTERACTIVE_5 = "5"; //
    public static final String INTERACTIVE_6 = "6"; //
    //问题类型： 1：学生作品问题；2：课堂问题; 3.互动资源

    public static final String QUEST_TYPE_0 = "0"; //
    public static final String QUEST_TYPE_1 = "1"; //
    public static final String QUEST_TYPE_3 = "3"; //
    //类型：1：学生作品；2：课堂问题；3：课堂表现,4：弹幕 5 互动资源,6 荣耀榜学生评分,7学生抢答,8随机挑人,9小组评分,10荣耀榜小组评分

    public static final String STUDENT_TYPE_1 = "1"; //
    public static final String STUDENT_TYPE_2 = "2"; //
    public static final String STUDENT_TYPE_3 = "3"; //
    public static final String STUDENT_TYPE_4 = "4"; //
    public static final String STUDENT_TYPE_5 = "5";
    public static final String STUDENT_TYPE_6 = "6";
    public static final String STUDENT_TYPE_7 = "7";
    public static final String STUDENT_TYPE_8 = "8";
    public static final String STUDENT_TYPE_9 = "9";
    public static final String STUDENT_TYPE_10 = "10";
    //类型：1：作业对比；2：作品对比；3：移动讲台,4：高拍仪,5：截屏


    /** 资源来源 */
    public static final String RES_SOURCE_DISK = "0"; // 网盘
    public static final String RES_SOURCE_POST = "1"; // 文章
    public static final String RES_SOURCE_MSGZS = "2"; // 名师工作室
    public static final String RES_SOURCE_BSK = "3"; // 备授课
    public static final String RES_SOURCE_WLJY = "4"; // 网络教研
    public static final String RES_SOURCE_HZHB = "5"; // 合作伙伴
    public static final String RES_SOURCE_JXZS_PC = "8"; // 教学助手PC端
    public static final String RES_SOURCE_JXZS_WEB = "9"; // 教学助手WEB端
    public static final String RES_SOURCE_ZQGS = "11"; // 中庆公司
    public static final String RES_SOURCE_OWY = "12"; // 奥威亚
    public static final String RES_SOURCE_ALBUM = "13"; // 我的相册
    public static final String RES_SOURCE_ARTICLE = "14"; // 文章附件
    public static final String RES_SOURCE_COURSE = "15"; // 资源备课

    public static final String FILE_TYPE_HOMEWORKCOMPARE = "1"; //
    public static final String FILE_TYPE_WORKCOMPARE = "2"; //
    public static final String FILE_TYPE_MOBILEPALATFORM = "3"; //
    public static final String FILE_TYPE_HIGHSPEEDPHOTO = "4"; //
    public static final String FILE_TYPE_SCREENSHOT = "5"; //

    public static final String ORDER_BY_DEFAULT = "0";//默认排序
    public static final String ORDER_BY_SCORE = "1";//评分排序
    public static final String ORDER_BY_COLLECTCOUNT = "2";//收藏排序
    public static final String ORDER_BY_VIEWCOUNT = "3";//浏览量排序
    public static final String ORDER_BY_FILELENGTH = "4";//大小排序


    public static final String IS_CLASSIC = "2,3,5";// 2,3,5表示 精品资源

    public static final String CMS_RESULT = "000000";// CMS接口返回标识

    public static final String COLLECT_CLASSIC = "2";
    public static final String COLLECT_EDU_RES = "3";

    public static final Integer COURSE_PAGE_SIZE = 10;

    public static final String CLASS_STUDENT = "0";
    public static final String CLASS_TEACHER = "1";
    public static final String CLASS_PARENT = "2";
    public static final String CLASS_ClASS = "3";//根据班级id查询
    /**
     * 关键版本时间点 date1 V1.7
     */
    public static final String VERSION_DATE_1 = "2016-02-29";


    public static final String CLASS_ROOM_PUSH = "1";//消息已经推送

    public static final String CLASS_ROOM_NOT_PUSH = "0";//消息没推送

    public static final String RES_ROOM_SYN = "1";//资源已经同步

    public static final String RES_ROOM_NOT_SYN = "0";//资源已经同步

    public static final String RES_ROOM_SYN_FAIL = "2";//资源同步失败

    public final static SerializerFeature[] features = {SerializerFeature.SortField,
            SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty,
            SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty,
            SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat};

    public static final String SHARE_RES = "1";//共享资源

    public static final String SHARE_RES_BOU = "2";//精品资源

    public static final String SHARE_RES_CLOUD = "5";//云资源

    public static final String SHARE_RES_XUEKE = "7";//学科资源

    public static final String SHARE_PRE_SHARE = "3";//共享课件

    public static final String SHARE_PRE_BOU = "4";//精品课件

    public static final String CLASS_ROOM = "6";//互动课堂

    public static final String SHARE_HM_RES = "12";//海马资源
    public static final String USERID_CLASSIC = "wutytx";//精品用户ID

    public static final long TIME = 3000;


    public static final String BOU_DISPLAY = "1"; //显示精品资源

    //分享转码是否完成

    public static final String SHARE_TRANS_SUCCESS = "0"; //分享成功
    public static final String SHARE_NO_TRANS = "1"; // 转码未完成

    //默认平台编码
    public static final String PLATFORM_CODE_DEFAULT = "888888"; // 默认平台编码

    //默认平台编码
    public static final String PLATFORM_CODE_KEQIAO_NEW = SysConfig.getStrValue("platform_code_entity"); // 柯桥平台
    public static final String PLATFORM_CODE_KEQIAO = "0"; // 0,柯桥平台

    //自定义教材
    public static final String IS_OWNER = "1"; // 1,自定义教材
    public static final String IS_OWNER_CMS = "2"; // 2,CMS自定义教材
    //自定义教材
    public static final String STATICS_DAY = "1"; // 1,按照天统计
    public static final String STATICS_WEEK = "2"; // 2,按照天统计
    public static final String STATICS_MONTH = "3"; // 3,按照天统计
    public static final String STATICS_YEAR = "4"; // 4,按照天统计

    //实体平台配置
    public static final String PLATFORM_CODE_ENTITY = "1"; // 实体平台编码

    //互动课堂资源来源类型
    public static final String INTERACTIVE_SOURCE_ALIYUN = "0"; // 阿里云
    public static final String INTERACTIVE_SOURCE_PRO_SERVER = "1"; // 服务器
    public static final String INTERACTIVE_SOURCE_RES_TABLE = "2"; // 资源表
    public static final String INTERACTIVE_SOURCE_TENCENT = "5"; //腾讯云

    //备课任务积分编码
    public static final String JY_PLAN_JF_CODE_JA = "ja001";//教案,当前课时有教案
    public static final String JY_PLAN_JF_CODE_KJ = "kj001";//课件，当前课时有课件
    public static final String JY_PLAN_JF_CODE_SK = "sk001";//授课，当前课时有授课记录
    public static final String JY_PLAN_JF_CODE_FS = "fs001";//反思，单个计划反思个数有上限
    public static final String JY_PLAN_JF_CODE_ZY_01 = "zy001";//作业，学生提交并已批阅
    public static final String JY_PLAN_JF_CODE_ZY_02 = "zy002";//作业，学生提交但未批阅
    public static final String JY_PLAN_JF_CODE_ZY_03 = "zy003";//作业，学生未提交
    public static final String JY_PLAN_JF_CODE_SC = "sc001";//素材，学生未提交

    //资源关联表
    public static final String COURSE_TYPE_CREATE_BY_MY="0";//自己创建
    public static final String COURSE_TYPE_CREATE_BY_SHARE="1";//共享收藏
    public static final String COURSE_STATUS="0";//资源状态
    public static final String COURSE_IMPORT="4";//精品导入


    /** 导学 **/
    public static final String MY_GUIDANCE = "0";
    public static final String SHARE_GUIDANCE = "1";
    public static final String CLASSIC_GUIDANCE = "2";

    /**分享范围常量 0：还未分享 1：学校 2：区域   3：平台所有人 8:集备资源**/
    public static final String SHARE_COLLECTIVE_PREPARATION="8";
    public static final String SHARE_ALL="3";
    public static final String SHARE_AREA="2";
    public static final String SHARE_SCHOOL="1";
    public static final String SHARE_NO="0";

    public static final String SHARE_PRIVINCE="4";
    public static final  String SHARE_CITY="5";
    public static final String SHARE_AREA_NEW="6";

    public static final String SHARE_BOUTIQUE="9";//精品资源存入分享表


    public static final String SHARE_TYPE_PRIVINCE="10";
    public static final  String SHARE_TYPE_CITY="11";
    public static final String SHARE_TYPE_AREA_NEW="12";

    public static final long REDIS_DEFAULT_EXPIRES = 7200;

    //获取产品图标
    /**
     * word前图标a标签使用 class:doc,docx
     */
    public static List<String> ioc_doc = Arrays.asList("doc", "docx");
    /**
     * pdf前图标a标签使用class:pdf
     */
    public static List<String> ioc_pdf = Collections.singletonList("pdf");
    /**
     * wps前图标a标签使用class:wps
     */
    public static List<String> ioc_wps = Collections.singletonList("wps");
    /**
     * html前图标a标签使用class:html,htm
     */
    public static List<String> ioc_html = Arrays.asList("html", "htm");
    /**
     * ppt前图标a标签使用class:ppt,pptx
     */
    public static List<String> ioc_ppt = Arrays.asList("ppt", "pptx");
    /**
     * image前图标a标签使用class:image,gif,png,jpg,jpeg,bmp
     */
    public static List<String> ioc_image = Arrays.asList("image", "gif", "jpg", "jpeg", "png", "bmp", "tiff");
    /**
     * movie前图标a标签使用class:movie,rmvb,wmv,swf,asf,flv,mpg,avi,rm,m v,mp4
     */
    public static List<String> ioc_movie = Arrays.asList("movie", "swf", "flv", "mov", "mp4", "rmvb", "avi", "wmv", "rm", "wmv9", "3gp", "asf", "asx", "mpg");
    /**
     * xls前图标a标签使用class:xls,et,xlsx
     */
    public static List<String> ioc_xls = Arrays.asList("xls", "xlsx", "et");
    /**
     * txt前图标a标签使用class:txt
     */
    public static List<String> ioc_txt = Collections.singletonList("txt");
    /**
     * music前图标a标签使用class:music,mp3,wma,mp2
     */
    public static List<String> ioc_music = Arrays.asList("music", "mp3", "wma", "mp2", "m4a", "wav");
    /**
     * file前图标a标签使用class:file
     */
    public static List<String> ioc_file = Collections.singletonList("file");

    /**
     * 当前数据库版本（oracle or mysql）
     */
    public static final String CURRENT_DATABASE_ORACLE = "oracle";


    public static List<String> picList = Arrays.asList("pdf","gif", "jpg", "jpeg", "png", "bmp", "tiff", "img");

    public static List<String> videoList = Arrays.asList("video","swf", "flv", "mov", "mp4", "rmvb", "avi", "wmv", "rm", "3gp", "asf", "asx", "mpg", "mkv", "vob", "mpeg", "ts", "f4v", "webm", "movie");

    public static List<String> audioList = Arrays.asList("mp1", "mp2", "mp3", "ogg", "wma", "aac", "m4a", "amr",  "flac", "wav");

    public static List<String> WordList = Arrays.asList("doc", "docx");

    public static List<String> ExcelList = Arrays.asList("xls", "xlsx");

    /**
     * 获取文件类型样式名
     *
     * @param fileName
     * @return
     */
    public static String getFileFormat(String fileName) {
        if (StringUtils.isBlank(fileName)) {
            return "file";
        }
        if (fileName.lastIndexOf(".") < 0) {
            return "file";
        }
        String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()).toLowerCase();
        return getFileFormat2(fileExt);
    }

    public static String getFileFormat2(String fileExt) {
        if (StringUtils.isBlank(fileExt)) {
            return "file";
        }
        if (ioc_doc.contains(fileExt)) {
            return "doc";
        }
        if (ioc_pdf.contains(fileExt)) {
            return "pdf";
        }
        if (ioc_wps.contains(fileExt)) {
            return "wps";
        }
        if (ioc_html.contains(fileExt)) {
            return "html";
        }
        if (ioc_ppt.contains(fileExt)) {
            return "ppt";
        }
        if (ioc_image.contains(fileExt)) {
            return "image";
        }
        if (ioc_movie.contains(fileExt)) {
            return "movie";
        }
        if (ioc_xls.contains(fileExt)) {
            return "xls";
        }
        if (ioc_txt.contains(fileExt)) {
            return "txt";
        }
        if (ioc_music.contains(fileExt)) {
            return "music";
        }
        return "file";
    }

    /**
     * 资源来源 by Arthurrr 20190916
     */
    public static final String RES_FROM_LOCAL = "1";//实体资源（本地资源）
    public static final String RES_FROM_NET = "2";//网络资源
    public static final String RES_FROM_WPS = "3";//天喻使用WPS网盘存储的资源

    /**
     * 网盘资源
     */
    public static String IS_FOLDER_YES = "0"; // 是否文件夹: 是
    public static String IS_FOLDER_NO = "1"; // 是否文件夹：否
    public static String OWNER_TYPE_PERSONAL = "0"; // 个人资源
    public static String OWNER_TYPE_GROUP = "1"; // 群组资源
    public static String OWNER_TYPE_ORG = "2"; // 机构资源
    public static String OWNER_TYPE_PLATFORMCODE = "3"; // 平台资源


    public static final String  INIT_DISK_JOB = "init_disk_job";
    public static final String  SYN_SPECIAL_REPO = "syn_special_repo";
    public static final String  SYN_SPECIAL_REPO_STATUS = "syn_special_repo_status";

    public static final String  INIT_PROD_OWNER = "init_prod_owner";
    public static final String  INIT_SCHOOL_RES_PRIV = "init_school_res_priv";
    public static final String  INIT_DISK_STATUS="init_disks_status";
    public static final String  SYN_DISK_JOB = "syn_disk_job";
    public static final String  SYN_DISK_STATUS="syn_disks_status";
    public static final String  INIT_DISK_PLAT_STATUS="init_disks_plat_status";
    public static final String  SYN_DISK_PLAT_STATUS="syn_disks_plat_status";
    public static final String  SYN_DISK_PLAT_JOB = "syn_disk_plat_job";
    public static final String  SYN_SCHOOL_RES_PRIV = "syn_school_res_priv";

    /**
     * 查询类型
     */
    public static String QUERY_TYPE_PROD = "1"; // 资源下载
    public static String QUERY_TYPE_RES = "2"; // 产品下载

    /**
     * 下载类型
     */
    public static String DOWN_TYPE_RES = "0"; // 资源下载
    public static String DOWN_TYPE_PROD = "1"; // 产品下载

    public static final Map<String,String> resSourceMap = new HashMap<>();
    static {
        resSourceMap.put(RES_SOURCE_DISK, "网盘");
        resSourceMap.put(RES_SOURCE_POST, "文章");
        resSourceMap.put(RES_SOURCE_MSGZS, "名师工作室");
        resSourceMap.put(RES_SOURCE_BSK, "备授课");
        resSourceMap.put(RES_SOURCE_WLJY, "网络教研");
        resSourceMap.put(RES_SOURCE_HZHB, "合作伙伴");
        resSourceMap.put(RES_SOURCE_JXZS_PC, "教学助手PC端");
        resSourceMap.put(RES_SOURCE_JXZS_WEB, "教学助手WEB端");
        resSourceMap.put(RES_SOURCE_ZQGS, "中庆公司");
        resSourceMap.put(RES_SOURCE_OWY, "奥威亚");
        resSourceMap.put(RES_SOURCE_ALBUM, "我的相册");
        resSourceMap.put(RES_SOURCE_ARTICLE, "文章附件");
        resSourceMap.put(RES_SOURCE_COURSE, "资源备课");
    }



}